package com.ueboot.weishop.repository.role;

import com.ueboot.weishop.entity.role.Role;
import com.ueboot.weishop.entity.role.UserRole;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserRoleRepository extends CrudRepository<UserRole, Long> {

    @Query("SELECT u.role FROM UserRole u WHERE u.user.username = :username AND u.user.isDeleted = false")
    List<Role> findByUsername(@Param("username") String username);

}
